from rest_framework import serializers

from av_editor.models import MaterialFile
from common.constants import IMAGE_TYPE, VIDEO_TYPE


class MaterialFileSerializer(serializers.ModelSerializer):

    class Meta:
        model = MaterialFile
        exclude = ["is_deleted"]


class MaterialFileBriefSerializer(serializers.ModelSerializer):

    class Meta:
        model = MaterialFile
        fields = ["file", "thumbnail", "file_type", "suffix"]


class MakeVideoT1Serializer(serializers.ModelSerializer):
    left_image = serializers.PrimaryKeyRelatedField(queryset=MaterialFile.objects.filter(file_type=IMAGE_TYPE),
                                                    label='左边的图片')
    right_video = serializers.PrimaryKeyRelatedField(queryset=MaterialFile.objects.filter(file_type=VIDEO_TYPE),
                                                     label='右边的视频')
    bottom_image = serializers.PrimaryKeyRelatedField(queryset=MaterialFile.objects.filter(file_type=IMAGE_TYPE),
                                                      label='底部的图片')

    class Meta:
        model = MaterialFile
        fields = ["left_image", "right_video", "bottom_image"]